text

type text

An immutable data type for representing character strings.

Since

0.6.0

Functions

Link copied to clipboard
pure function char_at(index: integer): integer

Get a 16-bit code of a character at the specified index.

Link copied to clipboard
(alias) pure function charAt(index: integer): integer

Get a 16-bit code of a character at the specified index.

Alias
Link copied to clipboard
pure function compare_to(other: text): integer

Compares this text to another text.

Link copied to clipboard
(alias) pure function compareTo(other: text): integer

Compares this text to another text.

Link copied to clipboard
pure function contains(text: text): boolean

Returns true if this text contains the specified substring, otherwise returns false.

Link copied to clipboard
pure function empty(): boolean

Returns true if the text is empty, otherwise returns false.

Link copied to clipboard
(alias) pure function encode(): byte_array

Converts the text to UTF-8 encoded bytes.

Alias
Link copied to clipboard
pure function ends_with(suffix: text): boolean

Returns true if this text ends with the specified suffix, otherwise returns false.

Link copied to clipboard
(alias) pure function endsWith(suffix: text): boolean

Returns true if this text ends with the specified suffix, otherwise returns false.

Alias
Link copied to clipboard
pure function format(args: anything...): text

Uses this string as a format string and returns a string obtained by substituting the specified arguments. Uses java.lang.String.format internally.

Link copied to clipboard
pure static function from_bytes(bytes: byte_array, [ignore_errors: boolean]): text

Creates text from bytes, optionally handling invalid UTF-8 encoding.

Link copied to clipboard
pure function index_of(text: text): integer

Returns the position of the first occurrence of the specified substring within this text, or -1 if the text is not found.

pure function index_of(text: text, start: integer): integer

Returns the position of the first occurrence of the specified substring within this text, starting at the specified index, or -1 if the text is not found.

Link copied to clipboard
(alias) pure function indexOf(text: text): integer

Returns the position of the first occurrence of the specified substring within this text, or -1 if the text is not found.

Alias
(alias) pure function indexOf(text: text, start: integer): integer

Returns the position of the first occurrence of the specified substring within this text, starting at the specified index, or -1 if the text is not found.

Alias
Link copied to clipboard
pure function last_index_of(text: text): integer

Returns the index within this text of the last occurrence of the specified string, or -1 if not found.

pure function last_index_of(text: text, max: integer): integer

Returns the index within this text of the last occurrence of the specified string, starting from the specified startIndex, or -1 if not found.

Link copied to clipboard
(alias) pure function lastIndexOf(text: text): integer

Returns the index within this text of the last occurrence of the specified string, or -1 if not found.

(alias) pure function lastIndexOf(text: text, max: integer): integer

Returns the index within this text of the last occurrence of the specified string, starting from the specified startIndex, or -1 if not found.

Link copied to clipboard
(alias) pure function len(): integer

Returns the number of characters in the text.

Alias
Link copied to clipboard
pure function like(pattern: text): boolean

Returns true if this text matches the specified pattern using SQL LIKE syntax.

Example:

val names = ["Alice", "Victor", "Viktor", "Victoria"];
print(names @* { .like("Vi_tor") }); // prints [Victor, Viktor]
print(names @* { .like("Vic%") }); // prints [Victor, Victoria]
Link copied to clipboard
pure function lower_case(): text

Returns a new text with all characters converted to lowercase.

Link copied to clipboard
(alias) pure function lowerCase(): text

Returns a new text with all characters converted to lowercase.

Link copied to clipboard
pure function matches(regex: text): boolean

Returns true if this text matches the given regular expression. Uses java.util.regex.Pattern internally.

Link copied to clipboard
pure function repeat(n: integer): text

Returns the text repeated n times. SQL compatible.

Link copied to clipboard
pure function replace(old_value: text, new_value: text): text

Returns a new text resulting from replacing all occurrences of old text in this text with new text.

Link copied to clipboard
pure function reversed(): text

Returns a reversed copy of the text. SQL compatible.

Link copied to clipboard
pure function size(): integer

Returns the number of characters in the text.

Link copied to clipboard
pure function split(delimiter: text): list<text>

Splits this text around matches of the given delimiter.

Link copied to clipboard
pure function starts_with(prefix: text): boolean

Returns true if this text starts with the specified prefix, otherwise returns false.

Link copied to clipboard
(alias) pure function startsWith(prefix: text): boolean

Returns true if this text starts with the specified prefix, otherwise returns false.

Link copied to clipboard
pure function sub(start: integer): text

Returns a substring of this text starting from the specified index.

pure function sub(start: integer, end: integer): text

Returns a substring of this text from the specified start index (inclusive) to the specified end index (exclusive).

Link copied to clipboard
pure function to_bytes(): byte_array

Converts the text to UTF-8 encoded bytes.

Link copied to clipboard
pure function trim(): text

Returns a new text with leading and trailing whitespace removed.

Link copied to clipboard
pure function upper_case(): text

Returns a new text with all characters converted to uppercase.

Link copied to clipboard
(alias) pure function upperCase(): text

Returns a new text with all characters converted to uppercase.